<?php
/**
 * 微信业务层
 * User: daxia
 * Date: 2020/10/11
 * Time: 16:38
 */

namespace app\common\service;

use EasyWeChat\Factory;
use think\Config;

class Wx
{

    public static $app;

    private static function init()
    {
        //小程序
        $config = Config::get('mini_program');
        self::$app = Factory::miniProgram($config);
    }

    public static function sendSubscribeMsg()
    {
        return false;
        self::init();

        //签约项目通知
        $msgId = "JtpzZeoL03qA5EHCqubKraqEDwzrZWZN0XbHr-TG3WA";
        $openId = "o0xgM0TOYh3gZsD5-a10Si8bhxzk";
        //发送订阅消息
        $result = self::$app->subscribe_message->send([
            'touser' => $openId,
            'template_id' => $msgId,
            'page' => 'pages/index/index',
            'data' => [
                'thing1' => ['value' => '测试'],
                'time4' => ['value' => date('Y-m-d H:i:s')],
            ],
        ]);
        var_dump($result);
    }

}